package com.qfedu.edu.vipservice.controller;


import com.qfedu.edu.po.Vip;
import com.qfedu.edu.result.R;
import com.qfedu.edu.vipservice.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaobobo
 * @since 2024-11-05
 */
@RestController
@RequestMapping("/vipservice/vip")
public class VipController {

    @Autowired
    private VipService vipService;

    /**
     * 通过用户名查询用户对象
      * @param username
     * @return
     */
    @GetMapping("/listUserByUsername")
    public R listUserByUsername(String username){
        //通过用户名查询用户对象
        Vip vip=vipService.listUserByUsername(username);
        return R.ok().data("vip",vip);
    }

    /**
     * 查询所有的用户
     * @return
     */
    @GetMapping("/list")
    @Secured("ROLE_vip")
    public R list(){
        //通过用户名查询用户对象
        List<Vip> list = vipService.list(null);
        return R.ok().data("list",list);
    }

}

